<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page isELIgnored="false"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet"
	href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
	integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
	crossorigin="anonymous">
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script
	src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"
	integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
	crossorigin="anonymous"></script>
	
	<script type="text/javascript">
		function onSelectChange(){
			var obj = document.getElementById('userSelect');
			var inputShoper = document.getElementById('textShopId');
			 
			var index =  obj.selectedIndex;
			inputShoper.value = obj.options[index].value;
			
		}
	
	</script>
<title>物品列表</title>
</head>
<body>

	<div class="container bs-docs-container">
		<br>
		<div class="panel panel-default">




			<div class="panel-heading">添加购物详细</div>

			<div class="panel-body">
				<div class="form-horizontal">
					<div class="form-group">
						<label for="goodsName" class="col-sm-2 control-label">购物人</label>
						<div class="col-sm-10">
							<select class="form-control" id="userSelect" onchange="onSelectChange()">
								<c:forEach items="${shopers}" var="t">
									<option  value="<c:out value="${t.id}" />"
										<c:if test="${selectedId==t.id}">
											<c:out value="selected=\"selected\"" />
										</c:if>
									 >
										<c:out value="${t.shoperName}" />
									</option>
								</c:forEach>
							</select>
						</div>
					</div>
				</div>


				<form class="form-horizontal"
					action="<%=request.getContextPath()%>/events/addDetail" method="post">
					<div class="hidden">
					<input type="text" name="shoperId"  id="textShopId" value="<c:out value="${selectedId}" />"/>
					</div>
					<div class="form-group">
						<label for="goodsName" class="col-sm-2 control-label">商品名称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="goodsName"
								placeholder="黄道益">
						</div>
					</div>

					<div class="form-group">
						<label for="goodsNum" class="col-sm-2 control-label">商品数量</label>
						<div class="col-sm-10">
							<input type="number" class="form-control" name="goodsNum"
							 	value="1"
								placeholder="goodsNum">
						</div>
					</div>

					<div class="form-group">
						<label for="goodsPrice" class="col-sm-2 control-label">购买价格</label>
						<div class="col-sm-10">
							<input type="number" step="0.01" class="form-control"
								name="goodsPrice" placeholder="价格">
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-primary">提交</button>
						</div>
					</div>



				</form>
			</div>
		</div>

		<br>
		<div class="panel panel-default">




			<div class="panel-heading">代购总收益</div>
			
			<div class="panel-body">
   
  
			
			<dl class="dl-horizontal">
				<dt>买入汇率</dt>
		      	<dd><c:out value="${income.realExchangeRate}" /></dd>
		      	<dt>卖出汇率</dt>
		      	<dd><c:out value="${income.saleExchangeRate}" /></dd>
		      	
		      	<dt>买入总价</dt>
		      	<dd><c:out value="${income.buyTotal}" /></dd>
		      	<dt>卖出总价</dt>
		      	<dd><c:out value="${income.saleTotal}" /></dd>
		      	<dt> </dt>
		      	<dd> <dd>
		      	<dt>总收益</dt>
		      	<dd><c:out value="${income.inCome}" /></dd>
			</dl>
			
			</div>
			
		</div>
		<br>
		<div class="panel panel-default">




			<div class="panel-heading">总明细</div>
			
			<div class="panel-body">
   
  
  			
  			
  			<c:forEach items="${details}" var="mymap" > 
  
  				<br>
			
				<table class="table table-striped">
				  <caption><c:out value="${mymap.key}"></c:out>的清单</caption>
				  	<thead>
				        <tr>
				          <th>商品名称</th>
				          <th>商品价格</th>
				          <th>数量</th>
				          <th>总价港币</th>
				          <th>总价人民币</th>
				        </tr>
				      </thead>
				      <c:set var="totalMoney" value="${0}"></c:set>
				      <tbody>
				      	<c:forEach items="${mymap.value}" var="t">
				      		<tr>
					          <td><c:out value="${t.goodsName}" /></td>
					          <td><c:out value="${t.goodsPrice}" /></td>
					          <td><c:out value="${t.goodsNum}" /></td>
					          <td><c:out value="${t.allMoney}" /></td>
					          <td><c:out value="${t.allMoneyRMB}" /></td>
					          <c:set var="totalMoney" value="${totalMoney+t.allMoneyRMB}"></c:set>
					        </tr>
				      	</c:forEach>
				      	 
				      
				      </tbody>
				      
				</table>
				
				<p class="text-right">总价：<strong><fmt:formatNumber value="${totalMoney}" pattern="#.#"/></strong></p>
				
				</c:forEach>
			
			</div>
			
		</div>

		


	</div>

</body>
</html>